Introduce rule SlevomatCodingStandard.Classes.ClassKeywordOrder#1817
Merged
kukulich merged 1 commit intoslevomat:masterfrom Dec 21, 2025
Merged
Introduce rule SlevomatCodingStandard.Classes.ClassKeywordOrder#1817kukulich merged 1 commit intoslevomat:masterfrom
kukulich merged 1 commit intoslevomat:masterfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This pull request introduces a new coding standard rule SlevomatCodingStandard.Classes.ClassKeywordOrder that enforces the correct order of class modifiers in PHP. The rule ensures that when multiple modifiers are used on a class declaration (such as final, abstract, and readonly), they appear in the correct order: abstract or final must come before readonly.
Key changes:
- Adds
ClassKeywordOrderSniffto detect and auto-fix incorrect modifier ordering - Includes comprehensive test coverage with error and no-error test cases
- Updates documentation and project configuration to enable the new rule
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| SlevomatCodingStandard/Sniffs/Classes/ClassKeywordOrderSniff.php | Implements the sniff to enforce correct class modifier ordering (final/abstract before readonly) with auto-fixer support |
| tests/Sniffs/Classes/ClassKeywordOrderSniffTest.php | Test suite validating the sniff detects errors correctly on lines 30 and 49 of the error file |
| tests/Sniffs/Classes/data/classKeywordOrderNoErrors.php | Test data containing valid class declarations with correct modifier ordering |
| tests/Sniffs/Classes/data/classKeywordOrderErrors.php | Test data with incorrect modifier ordering (readonly before final/abstract) |
| tests/Sniffs/Classes/data/classKeywordOrderErrors.fixed.php | Expected output after auto-fixing the errors |
| doc/classes.md | Adds documentation for the new ClassKeywordOrder sniff |
| README.md | Updates the sniff index to include the new rule |
| build/phpcs.xml | Enables the new rule in the project's own coding standards configuration |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
SlevomatCodingStandard/Sniffs/Classes/ClassKeywordOrderSniff.php
Outdated
Show resolved
Hide resolved
SlevomatCodingStandard/Sniffs/Classes/ClassKeywordOrderSniff.php
Outdated
Show resolved
Hide resolved
cf4fe3a to
851df63
Compare
851df63 to
b16eade
Compare
b16eade to
1513363
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.